<template>
  <div class="app-container">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
  <el-form-item label="旧密码" prop="password_old">
    <el-input v-model="formData.password_old" placeholder="请输入旧密码" clearable show-password></el-input>
  </el-form-item>
  <el-form-item label="新密码" prop="password_new">
    <el-input v-model="formData.password_new" placeholder="请输入新密码" clearable show-password></el-input>
  </el-form-item>
  <el-form-item label="新密码" prop="password_repeat">
    <el-input v-model="formData.password_repeat" placeholder="请再次输入新密码" clearable show-password></el-input>
  </el-form-item>
  <el-form-item size="large">
    <el-button type="primary" @click="submitForm">提交</el-button>
    <el-button @click="resetForm">重置</el-button>
  </el-form-item>
</el-form>
      </div>
</template>
<script>

export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        password_old: undefined,
        password_new: undefined,
        password_repeat: undefined,
      },
      rules: {
        password_old: [{
          required: true,
          message: '请输入旧密码',
          trigger: 'blur'
        }],
        password_new: [{
          required: true,
          message: '请输入新密码',
          trigger: 'blur'
        }],
        password_repeat: [{
          required: true,
          message: '请再次输入新密码',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(async valid => {
        if (!valid) return
        console.log(this.formData)
        let formData = this.formData
        let result = await this.$API.user.reqChangePassword(formData)
        if (result.code == 200) {
        	this.$message({
        		type: 'success',
        		message: result.msg
        	})
          this.resetForm()
        }
        // await this.$store.dispatch('user/logout')
        // this.$router.push(`/login`)
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}
</script>
